Skip to content

fix redis: check geo reply member is a string before GetString - #1288

Closed
netliomax25-code wants to merge 1 commit into
userver-framework:developfrom
netliomax25-code:redis-geo-reply-type-check
Closed

fix redis: check geo reply member is a string before GetString#1288
netliomax25-code wants to merge 1 commit into
userver-framework:developfrom
netliomax25-code:redis-geo-reply-type-check

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor

ParseReplyDataArray for GeoPoint in redis/src/storages/redis/parse_reply.cpp reads the first element of each per-member sub-array of a GEORADIUS/GEOSEARCH reply with GetString(), but only checks that the sub-array is non-empty rather than that the element is a string. ReplyData::GetString() resolves through std::get_if, which returns nullptr for a non-string element, so a compromised or MITM'd Redis server that returns an integer or nested array there makes the parser dereference that null pointer while move-constructing member (a UASSERT abort under the sanitizer CI, a null-pointer dereference of a std::string in release). I added an IsString check before the read that throws ParseReplyException, matching the type checks the sibling branches already perform, and covered both the rejected and accepted reply shapes with a test.

@apolukhin

Copy link
Copy Markdown
Member

LGTM

@robot-magpie

robot-magpie Bot commented Jul 28, 2026

Copy link
Copy Markdown

Many thanks for the PR! @apolukhin is now importing your pull request into our internal upstream repository.

@robot-magpie

robot-magpie Bot commented Jul 29, 2026

Copy link
Copy Markdown

✅ This pull request is being closed because it has been successfully merged into our internal monorepository.
Your changes will be pushed to this repository soon. Thank you for your contribution!

@robot-magpie robot-magpie Bot closed this Jul 29, 2026
robot-piglet pushed a commit that referenced this pull request Jul 29, 2026
ParseReplyDataArray for GeoPoint in redis/src/storages/redis/parse_reply.cpp reads the first element of each per-member sub-array of a GEORADIUS/GEOSEARCH reply with GetString(), but only checks that the sub-array is non-empty rather than that the element is a string. ReplyData::GetString() resolves through std::get_if, which returns nullptr for a non-string element, so a compromised or MITM'd Redis server that returns an integer or nested array there makes the parser dereference that null pointer while move-constructing member (a UASSERT abort under the sanitizer CI, a null-pointer dereference of a std::string in release). I added an IsString check before the read that throws ParseReplyException, matching the type checks the sibling branches already perform, and covered both the rejected and accepted reply shapes with a test.

---

Pull Request resolved: #1288

Co-authored-by: antoshkka <antoshkka@userver.tech>
Co-authored-by: antoshkka <antoshkka@userver.tech>
commit_hash:b85b0638c485003329d835727ec440421d342412
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants